<?php
class main extends JXZWMSController
{
	function index(){
        $confignum=array('id'=>1);
        $jxz_confing=JXZWMSClass("confing");
        $confignr=$this->confignr=$jxz_confing->find($confignum);
		$this->diJXZWMSlay("index.html");
	}
    function login(){
        $jxz_admin=JXZWMSClass("admin");
        $new=array(
        $us_name=$this->JXZWMSArgs('username'),
        $us_password=$this->JXZWMSArgs('userpassword'),
        );
            $jxz_admin->verifier=$jxz_admin->verifier_login;
    $new=$jxz_admin->JXZWMSVerifier($this->JXZWMSArgs());
    if(false==$new){
        if(false==$jxz_admin->userlogin($us_name,$us_password)){
            $this->error("用户名或者密码输入错误");
        }else{
            JXZWMSClass('JXZWMSAcl')->set("admin"); 
           $this->success("登录成功",JXZWMSUrl("main","adminindex")); 
            }
                }else{
            foreach($new as $item){
                    foreach($item as $msg){
                        $this->error($msg,JXZWMSUrl("main","index"));
        }
        }
        }
    }
    
    function adminindex(){
        $this->diJXZWMSlay("adminlogin.html"); 
    }
    
    function guaji(){
        $danny=array('id'=>1);
        $jxz_jxza=JXZWMSClass("timea");
        $jxz_jxz=JXZWMSClass("time");
        $zzb=array('num'=>0);
        $zza=$this->zza=$jxz_jxz->findCount($zzb);
        $zzc=$this->zzc=$jxz_jxza->find($danny);
        $zzd=$zzc['num'];
        if($zza !=$zzd){
                $zzc=array('id'=>1);
                $zzd=array('num'=>$zza);
                $jxz_jxza->update($zzc,$zzd);
                         echo '<embed src="sucai/tixing.mp3" width=0 height=0 type=audio/mpeg loop="1"   autostart="true">';
                $this->diJXZWMSlay("guaji.html"); 

        }else{
                $this->diJXZWMSlay("guaji.html"); 
        }
 
    }
    
        function more(){
       $this->diJXZWMSlay("more.html");  
    }
    
    function header(){
         $this->diJXZWMSlay("header.html");
    }
    
        function menu(){
        $this->diJXZWMSlay("menu.html"); 
    }
    
        function adminedit(){
        $jxz_admin=JXZWMSClass("admin");
        $row=array('id'=>$this->JXZWMSArgs("id"));
        $new=$this->new=$jxz_admin->find($row);
        $this->diJXZWMSlay("adminedit.html");
    }
    
        function admineditzz(){
      $jxz_admin=JXZWMSClass("admin");
      $new=array(
      'userpassword'=>$this->JXZWMSArgs('userpassword'),
      );
      $row=array('id'=>$this->JXZWMSArgs("id")); 
       if($new[userpassword]==""){
        $this->success("还没有输入密码");
       }else{   
      $jxz_admin->update($row,$new);
      $this->success("密码修改成功");
    }
    }
    
       function logout(){
	   	$_SESSION = array();
	  	if (isset($_COOKIE[session_name()])) {setcookie(session_name(), '', time()-42000, '/');}
	   	session_destroy();
	   	$this->success("安全退出系统", JXZWMSUrl("main","index"));
	}
    
      function jxzadd(){
        $this->diJXZWMSlay("jxzadd.html");
      }
    
        function shopaddzz(){
            $row=array(
            'num'=>$this->JXZWMSArgs('num'),
            'type'=>$this->JXZWMSArgs('type'),
            'pay'=>$this->JXZWMSArgs('pay'),
            'goodnum'=>$this->JXZWMSArgs('goodnum'),
            'badnum'=>$this->JXZWMSArgs('badnum'),
            'shopname'=>$this->JXZWMSArgs('shopname'),
            'images'=>$this->JXZWMSArgs('images'),
            'fbtime'=>date("Y-m-d H:i:s"),
            );
            $jxz_shop=JXZWMSClass("shop");
            $jxz_shop->create($row);
            $this->success("添加产品成功",JXZWMSUrl("main","jxzadd"));
        }
    
    function jxzlist(){
        $jxz_shop=JXZWMSClass("shop");
        $b=$jxz_shop->findAll();
        $b=$this->b=$jxz_shop->JXZWMSPager($this->JXZWMSArgs('page', 1), 15)->findAll(null, " fbtime DESC ");
        $this->pager = $jxz_shop->JXZWMSPager()->getPager();
        $fenye=$this->fenye=$this->JXZWMSArgs('name');
        $this->diJXZWMSlay("jxzlist.html");
    }
    
    
        function shopdel(){
         $jxz_shop=JXZWMSClass("shop");
        $row=array('id'=>$this->JXZWMSArgs("id"));
        $jxz_shop->delete($row);
        $this->success("刪除成功");
    }
    
    function book(){
         $jxz_ly=JXZWMSClass("book");
       $row=array(
            'who'=>$this->JXZWMSArgs('who'),
            'contents'=>$this->JXZWMSArgs('contents'),
            'time'=>date("Y-m-d H:i:s"),
            ); 
           $jxz_ly->create($row); 
           JXZWMSclass('JXZWMSlog')->warn("有新的短消息待查收");
                     $newtime=filemtime("temp/.access.warning.log");
             $jxz_jxz=JXZWMSClass("time");
            $rowtime=array('time'=>$newtime);
             $jxz_jxz->create($rowtime);
           $this->success("留言成功",JXZWMSUrl("main","index"));
    }
    
    function message(){
              $jxz_ly=JXZWMSClass("book");
        $b=$jxz_ly->findAll();
        $b=$this->b=$jxz_ly->JXZWMSPager($this->JXZWMSArgs('page', 1), 15)->findAll(null, " time DESC ");
        $this->pager = $jxz_ly->JXZWMSPager()->getPager();
        $fenye=$this->fenye=$this->JXZWMSArgs('name');
        $this->diJXZWMSlay("message.html");  
    }
    
    function bookdel(){
         $jxz_ly=JXZWMSClass("book");
        $row=array('id'=>$this->JXZWMSArgs("id"));
        $jxz_ly->delete($row);
        $this->success("刪除成功");
    }
    
    
    function two(){
        $jxz_shop=JXZWMSClass("shop");
        $b=$jxz_shop->findAll();
        $b=$this->b=$jxz_shop->JXZWMSPager($this->JXZWMSArgs('page', 1), 15)->findAll(null, " fbtime DESC ");
        $this->pager = $jxz_shop->JXZWMSPager()->getPager();
        $fenye=$this->fenye=$this->JXZWMSArgs('name');
        	   $confignum=array('id'=>1);
       $jxz_confing=JXZWMSClass("confing");
        $confignr=$this->confignr=$jxz_confing->find($confignum);
        JXZWMSclass('JXZWMSlog')->warn("有新的员工登录");
                     $newtime=filemtime("temp/.access.warning.log");
             $jxz_jxz=JXZWMSClass("time");
            $rowtime=array('time'=>$newtime);
             $jxz_jxz->create($rowtime);
        $this->diJXZWMSlay("two.html");
    }
    
    function three(){
        $jxz_shop=JXZWMSClass("shop");
        $id=$this->JXZWMSArgs('id');
        $a=array('id'=>$this->JXZWMSArgs('id'));
        $name=$this->JXZWMSArgs('name');
        $this->name=$name;
        $num=$this->JXZWMSArgs('num');
        $this->num=$num;
        $this->id=$id;
        $row=$this->row=$jxz_shop->find($a);
        	   $confignum=array('id'=>1);
       $jxz_confing=JXZWMSClass("confing");
        $confignr=$this->confignr=$jxz_confing->find($confignum);
        $this->diJXZWMSlay("three.html");
    }
    

    
    function threea(){
        $row=array(
            'pay'=>$this->JXZWMSArgs('pay'),
            'goodnum'=>$this->JXZWMSArgs('goodnum'),
            'badnum'=>$this->JXZWMSArgs('badnum'),
            'shopname'=>$this->JXZWMSArgs('shopname'),
            'num'=>$this->JXZWMSArgs('num'),
            'cid'=>$this->JXZWMSArgs('id'),
            'gxtime'=>date("Y-m-d H:i:s"),
            );
            $this->row=$row;
                   $jxz_shopls=JXZWMSClass("temporary");
                $danny=array('id'=>$this->JXZWMSArgs('id'));
                $jxz_shopls->create($row);
        $confignum=array('id'=>1);
       $jxz_confing=JXZWMSClass("confing");
        $confignr=$this->confignr=$jxz_confing->find($confignum);
        JXZWMSclass('JXZWMSlog')->warn("有新的入库申请");
        $newtime=filemtime("temp/.access.warning.log");
                     $jxz_jxz=JXZWMSClass("time");
            $rowtime=array('time'=>$newtime);
             $jxz_jxz->create($rowtime);
            $this->diJXZWMSlay("four.html");
    }
    
    function threeb(){
          $rows = JXZWMSAccess('r' , 'testname');
         $this->rows=$rows;
                 $confignum=array('id'=>1);
       $jxz_confing=JXZWMSClass("confing");
        $confignr=$this->confignr=$jxz_confing->find($confignum);
        $this->diJXZWMSlay("four-index.html");
    }
    
    function temporary(){
         $row=array(
            'gxtime'=>date("Y-m-d H:i:s"),
            'shopname'=>$this->JXZWMSArgs('shopname'),
            'num'=>$this->JXZWMSArgs('num'),
            'cid'=>$this->JXZWMSArgs('id'),
            'gdpay'=>$this->JXZWMSArgs('gdpay'),
            'bz'=>$this->JXZWMSArgs('bz'),
            ); 
             JXZWMSAccess('w',  'testname', $row, 3600);
            $jxz_shopls=JXZWMSClass("temporary");
 $jxz_shopls->verifier=$jxz_shopls->verifier_temporarya;
    $new=$jxz_shopls->JXZWMSVerifier($this->JXZWMSArgs());
    if(false==$new){
             $jxz_shopls->create($row);
            JXZWMSclass('JXZWMSlog')->warn("有新的入库申请");
                     $newtime=filemtime("temp/.access.warning.log");
             $jxz_jxz=JXZWMSClass("time");
            $rowtime=array('time'=>$newtime);
             $jxz_jxz->create($rowtime);
            $this->success("重新填写",JXZWMSUrl("main","threeb"));
                }else{
            foreach($new as $item){
                    foreach($item as $msg){
                        $this->error($msg,JXZWMSUrl("main","two"));
        }
        }
        }
    }
    
        function linshia(){
         $row=array(
            'shopname'=>$this->JXZWMSArgs('shopname'),
            'gxtime'=>date("Y-m-d H:i:s"),
            'num'=>$this->JXZWMSArgs('num'),
            'cid'=>$this->JXZWMSArgs('id'),
            'bdpay'=>$this->JXZWMSArgs('bdpay'),
            'bza'=>$this->JXZWMSArgs('bza'),
            );   
            $jxz_shopls=JXZWMSClass("linshi");
 $jxz_shopls->verifier=$jxz_shopls->verifier_linshib;
    $new=$jxz_shopls->JXZWMSVerifier($this->JXZWMSArgs());
    if(false==$new){
             $jxz_shopls->create($row);
            JXZWMSclass('JXZWMSlog')->warn("有新的入库申请");
                     $newtime=filemtime("temp/.access.warning.log");
             $jxz_jxz=JXZWMSClass("time");
            $rowtime=array('time'=>$newtime);
             $jxz_jxz->create($rowtime);
            $this->success("重新填写",JXZWMSUrl("main","two"));
                }else{
            foreach($new as $item){
                    foreach($item as $msg){
                        $this->error($msg,JXZWMSUrl("main","two"));
        }
        }
        }
    }
    
    
    function temporaryshow(){
        $jxz_shopls=JXZWMSClass("temporary");
        $b=$jxz_shopls->findAll();
        $b=$this->b=$jxz_shopls->JXZWMSPager($this->JXZWMSArgs('page', 1), 15)->findAll(null, " gxtime DESC ");
        $this->pager = $jxz_shopls->JXZWMSPager()->getPager();
        $fenye=$this->fenye=$this->JXZWMSArgs('name');
        $this->diJXZWMSlay("temporaryshow.html");
    }
    
    function temporarydel(){
        $jxz_shopls=JXZWMSClass("temporary");
        $row=array('id'=>$this->JXZWMSArgs("id"));
        $jxz_shopls->delete($row);
        $this->success("刪除成功"); 
    }
    
    function temporaryok(){
        $a=array('id'=>$this->JXZWMSArgs('id'));
          $jxz_shopls=JXZWMSClass("temporary");
                    $jxz_shop=JXZWMSClass("shop");
          $row=$this->row=$jxz_shopls->find($a);
          $num=array('id'=>$row['cid']);
            $zz=$this->zz=$jxz_shop->find($num);
            dump ($zz);
                $b=$zz['goodnum'];
                $c=$zz['badnum'];
          $new=array(
          'num'=>$row['num'],
          'pay'=>$row['pay'],
          'goodnum'=>$row['goodnum']+$b,
          'badnum'=>$row['badnum']+$c,
          'gxtime'=>$row['gxtime'],
          ); 
          dump ($new);
          $jxz_shop->update($num, $new);
         $newrow=array('yesno'=>1);
          $jxz_shopls->update($a, $newrow);
          $this->success("审批完成");
    }
    
        function temporaryoka(){
        $a=array('id'=>$this->JXZWMSArgs('id'));
          $jxz_shopls=JXZWMSClass("temporary");
                    $jxz_shop=JXZWMSClass("shop");
          $row=$this->row=$jxz_shopls->find($a);
          $num=array('id'=>$row['cid']);
            $zz=$this->zz=$jxz_shop->find($num);
            dump ($zz);
                $b=$zz['goodnum'];
                $c=$zz['badnum'];
          $new=array(
          'gxtime'=>$row['gxtime'],
         'gdpay'=>$row['gdpay'],
          'bz'=>$row['bz'],
          ); 
          dump ($new);
          $jxz_shop->update($num, $new);
          $newrow=array('yesno'=>1);
          $jxz_shopls->update($a, $newrow);
          $this->success("审批完成");
    }
    
    
        function temporaryokb(){
        $a=array('id'=>$this->JXZWMSArgs('id'));
          $jxz_shopls=JXZWMSClass("temporary");
                    $jxz_shop=JXZWMSClass("shop");
          $row=$this->row=$jxz_shopls->find($a);
          $num=array('id'=>$row['cid']);
            $zz=$this->zz=$jxz_shop->find($num);
            dump ($zz);
                $b=$zz['goodnum'];
                $c=$zz['badnum'];
          $new=array(
          'gxtime'=>$row['gxtime'],
          'bdpay'=>$row['bdpay'],
          'bza'=>$row['bza'],
          ); 
          dump ($new);
          $jxz_shop->update($num, $new);
          $newrow=array('yesno'=>1);
          $jxz_shopls->update($a, $newrow);
          $this->success("审批完成");
    }
    function confing(){
        $a=array('id'=>1);
        $jxz_confing=JXZWMSClass("confing");
        $row=$this->row=$jxz_confing->find($a);
        $this->diJXZWMSlay('confing.html');
    }
    
    function confingedit(){
        $num=array('id'=>1);
        $row=array(
        'onename'=>$this->JXZWMSArgs('onename'),
        'twoname'=>$this->JXZWMSArgs('twoname'),
        'threename'=>$this->JXZWMSArgs('threename'),
        'fourname'=>$this->JXZWMSArgs('fourname'),
        'fivename'=>$this->JXZWMSArgs('fivename'),
        'titel_color'=>$this->JXZWMSArgs('titel_color'),
        'title_font'=>$this->JXZWMSArgs('title_font'),
                        'titel_colora'=>$this->JXZWMSArgs('titel_colora'),
        'title_fonta'=>$this->JXZWMSArgs('title_fonta'),
                'titel_colorb'=>$this->JXZWMSArgs('titel_colorb'),
        'title_fontb'=>$this->JXZWMSArgs('title_fontb'),
                          'titel_colorc'=>$this->JXZWMSArgs('titel_colorc'),
        'title_fontc'=>$this->JXZWMSArgs('title_fontc'),  
         'titel_colord'=>$this->JXZWMSArgs('titel_colord'),
        'title_fontd'=>$this->JXZWMSArgs('title_fontd'),     
        );
            $jxz_confing=JXZWMSClass("confing");
            $jxz_confing->update($num,$row); 
            $this->success("修改标语成功");  
    }
    
    function goout(){
        $new=array(
         'brivername'=>$this->JXZWMSArgs('brivername'),
         'brivernum'=>$this->JXZWMSArgs('brivernum'),
         'sale'=>$this->JXZWMSArgs('sale'),
         'tel'=>$this->JXZWMSArgs('tel'),
         'qq'=>$this->JXZWMSArgs('qq'),
         'city'=>$this->JXZWMSArgs('city'),
         'dont'=>$this->JXZWMSArgs('dont'),
         'dontmodel'=>$this->JXZWMSArgs('dontmodel'),
         'dontnum'=>$this->JXZWMSArgs('dontnum'),
         'overdue'=>$this->JXZWMSArgs('overdue'),
         'time'=>date("Y-m-d H:i:s"),
          ); 
         $jxz_goout=JXZWMSClass("goout"); 
         $jxz_goout->create($new); 
                    JXZWMSclass('JXZWMSlog')->warn("有新的出入库表单");
                     $newtime=filemtime("temp/.access.warning.log");
             $jxz_jxz=JXZWMSClass("time");
            $rowtime=array('time'=>$newtime);
             $jxz_jxz->create($rowtime);
         $this->success("提交成功",JXZWMSUrl("main","two"));
    }
    
    function gooutlist(){
               $jxz_goout=JXZWMSClass("goout");
        $b=$jxz_goout->findAll();
        $b=$this->b=$jxz_goout->JXZWMSPager($this->JXZWMSArgs('page', 1), 15)->findAll(null, " time DESC ");
        $this->pager = $jxz_goout->JXZWMSPager()->getPager();
        $fenye=$this->fenye=$this->JXZWMSArgs('name');
        $this->diJXZWMSlay("gooutlist.html"); 
    }
    
            function gooutdel(){
         $jxz_goout=JXZWMSClass("goout");
        $row=array('id'=>$this->JXZWMSArgs("id"));
        $jxz_goout->delete($row);
        $this->success("刪除成功");
    }
    
}